package com.tedu.user.service.impl;

import com.tedu.user.mapper.UserFeedbackMapper;
import com.tedu.user.pojo.dto.UserFeedbackParam;
import com.tedu.user.pojo.dto.UserFeedbackQuery;
import com.tedu.user.pojo.entity.UserFeedback;
import com.tedu.user.pojo.vo.UserFeedbackVO;
import com.tedu.user.service.UserFeedbackService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class UserFeedbackServiceImpl implements UserFeedbackService {
    @Autowired
    private UserFeedbackMapper userFeedbackMapper;
    @Override
    public void saveUserFeedback(UserFeedbackParam userFeedbackParam) {
        log.debug("保存用户反馈业务,参数:{}",userFeedbackParam);
        UserFeedback userFeedback = new UserFeedback();
        BeanUtils.copyProperties(userFeedbackParam,userFeedback);
        userFeedbackMapper.insert(userFeedback);


    }

    @Override
    public List<UserFeedbackVO> selectUserFeedback(UserFeedbackQuery userFeedbackQuery) {
        log.debug("用户反馈业务,参数:{}",userFeedbackQuery);
        List<UserFeedbackVO> list = userFeedbackMapper.selectUserFeedback(userFeedbackQuery);
        System.out.println(list);
        return list;
    }

    @Override
    public void deleteFeedback(Long feedbackId) {
        log.debug("删除用户反馈业务,参数:{}",feedbackId);
        userFeedbackMapper.deleteById(feedbackId);
    }
}
